Page({
  data: {
    list: null,
    pageIndex: 1,
    noMore: false,
    loading: false,
    padding: '10rpx 20rpx'
  },
  onLoad: function () {
    this.myInvoice();
  },
  onReachBottom: function () {
    if (this.data.noMore) return;
    this.setData({
      loading: true
    });
    this.myInvoice();
  },
  onPageScroll: function (e) {
    this.setData({
      scrollTop: e.scrollTop
    });
  },
  myInvoice: function () {
    wx.util.request('', {
      query: `page=${this.data.pageIndex}`
    }).then(res => {
      this.setData({
        list: (this.data.list || []).concat(res),
        pageIndex: this.data.pageIndex + 1,
        noMore: res.length < 10,
        loading: false
      });
    });
  },
  orderDetail: function (e) {
    wx.navigateTo({
      url: `../order/detail?id=${e.currentTarget.dataset.id}`,
    })
  }
})